<template>
  <div id='info'>
    <header>
      <div>
        <div class="hd-l" @click='back'>
          <i class="iconfont icon-fanhui"></i>
        </div>
        <h2>账户信息</h2>
      </div>
    </header>
  
    <div class="common">
      <div class="same">
        <div class="left">
          <h2>头像</h2>
        </div>
        <div class="right">
          <img src="../assets/img/头像.jpg">
          <i class="iconfont icon-xiangyou"></i>
        </div>
      </div>
      <div class="same">
        <div class="left">
          <h2>用户名</h2>
        </div>
        <div class="right">
          <span>{{users.username}}</span>
        </div>
      </div>
    </div>
    <h2>账号绑定</h2>
    <div class="common">
      <div class="same">
        <div class="left">
          <svg viewBox="0 0 512 512" id="mobile" width="100%" height="100%">
            <path d="M368 0H144c-26.4 0-48 21.6-48 48v416c0 26.4 21.6 48 48 48h224c26.4 0 48-21.6 48-48V48c0-26.4-21.6-48-48-48zM192 24h128v16H192V24zm64 456c-17.673 0-32-14.327-32-32s14.327-32 32-32 32 14.327 32 32-14.327 32-32 32zm128-96H128V64h256v320z"></path>
          </svg>
          <h2>手机</h2>
        </div>
        <div class="right">
          <span>{{users.phone}}</span>
          <i class="iconfont icon-xiangyou"></i>
        </div>
      </div>
    </div>
    <h2>安全设置</h2>
    <div class="common">
      <div class="same">
        <div class="left">
          <h2>登录密码</h2>
        </div>
        <div class="right">
          <span>修改</span>
          <i class="iconfont icon-xiangyou"></i>
        </div>
      </div>
    </div>
    <button type="button" @click='signOut'>退出登录</button>
  </div>
</template>

<script>
export default {
  name: 'info',
  data() {
    return {
      users: {
        phone: '',
        username: ''
      }
    }
  },
  mounted() {
    var obj = JSON.parse(localStorage.getItem('mobile'));
    // console.log(obj);
    if (obj !== null) {
      this.loader = true;
      this.users.phone = obj.phone.substring(0, 3) + '****' + obj.phone.substring(7, 11);
      this.users.username = obj.username;
    }
  },
  methods: {
    back: function () {
      window.history.go(-1);
    },
    signOut: function () {
      localStorage.removeItem('mobile');
      this.$router.push({
        path: '/personal'
      })
    }
  }
}
</script>

<style lang='scss' scoped>
@import '../../static/hotcss/px2rem.scss';
#info {
  header {
    height: px2rem(44);
    padding-bottom: px2rem(15);
    >div {
      position: fixed;
      width: 100%;
      height: px2rem(44);
      z-index: 100;
      background-image: linear-gradient(to right, #00AAFF 0%, #0086FF 100%);
    }
    .hd-l {
      display: inline-block;
      width: px2rem(44);
      height: px2rem(44);
      text-align: center;
      vertical-align: top;
      line-height: px2rem(44);
      i {
        font-size: px2rem(18);
        color: #FFF;
      }
    }
    h2 {
      display: inline-block;
      position: absolute;
      top: 0;
      left: 50%;
      transform: translate(-50%, 0);
      color: #FFF;
      line-height: px2rem(44);
      font-size: px2rem(18);
    }
  }
  .common {
    background-color: #FFF;
    .same {
      padding: px2rem(15) px2rem(14);
      display: flex;
      justify-content: space-between;
      border-bottom: px2rem(0.5) solid #ddd;
      align-items: center;
      .left {
        h2 {
          font-size: px2rem(16);
          display: inline-block;
          vertical-align: middle;
          color: #333;
        }
        svg {
          width: px2rem(16);
          padding: px2rem(4) px2rem(1);
          border-radius: px2rem(5);
          background-color: #10AEFF;
          vertical-align: middle;
          fill: #FFF;
        }
      }
      .right {
        display: flex;
        align-items: center;
        img {
          width: px2rem(45);
          height: px2rem(45);
          border-radius: 50%;
          vertical-align: middle;
        }
        i {
          vertical-align: middle;
          display: inline-block;
          color: #999;
          font-size: px2rem(18);
        }
        span {
          font-size: px2rem(16);
          color: #999;
          font-weight: bold;
        }
      }
    }
  }
  >h2 {
    padding: px2rem(15) px2rem(14);
    font-weight: normal;
    color: #666;
    font-size: px2rem(18);
  }
  >button {
    display: block;
    width: 90%;
    margin: 0 auto;
    box-sizing: border-box;
    background-color: #FF5339;
    height: px2rem(48);
    line-height: px2rem(48);
    color: #FFF;
    font-size: px2rem(18);
    text-align: center;
    border: 0;
    padding: 0;
    margin-top: px2rem(15);
    font-weight: bold;
    border-radius: px2rem(5);
  }
}
</style>
